<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags" prefix="s" %>

<!doctype html>
<html>
<head>
	<link rel="stylesheet" type="text/css" href="UI/users/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="UI/users/css/main.css"/>
    <link href="bootstrap/css/bootstrap.min.css" rel="UI/users/stylesheet">
    <script type="text/javascript" src="UI/users/js/libs/modernizr.min.js"></script>
   	<script src="UI/users/bootstrap/js/bootstrap.min.js"></script>
    <style type="text/css">
    #content_operate_field_button {
	margin-right: 20px;
	margin-left: 20px;
	}
	</style>
<script type="text/javascript">
/* 	//基本校验-非空校验
	function valNull(value, name) {
		if (value =="") {
			alert(name +"值不能为空!");
		return false;
		}else{
			return true;
		}
	} */
/* 	function vertileGoodsAdd(){
		alert("验证输入");
		var price=document.getElementById("price");
		var goodskind=document.getElementById("goodskind");
		var ext = "/^[0-9]*$/";
		if(!ext.test(valueOf(price))){
			alert(price +"错误，请在价格中输入数字!");
			return false;
		}else{
			if(goodskind.value=="-1"){
				alert(goodskind +"错误，请选择商品种类!");
				return false;
			}else{
				return true;
			}
		}
	} */
/* 	//基本校验 数字
	function valNum(value, name) {
		var ext = /^[0-9]*$/;
		if (!ext.test(value)) {
			alert(name +"格式不正确!");
			return false;
		} else{
			
			return true;
		}
	}	 */
	function confirmAddGood(){
		var goodskind=document.getElementById("goodskind");
		var price=document.getElementById("price");
		var reg=/^[-\+]?\d+(\.\d+)?$/;
		if(goodskind.value=="-1"){
				alert("商品分类不能为空!");
				return false;
		}else{
			if(reg.test(price.value)){
				return true;
			}else{
				alert("输入正确的价格");
				return false;
			}
		}	
	}
</script>
</head>
<body>
<s:if test="null==#session.account">
	<s:a href="login.action" align="center"><h2>您不能直接访问网站内部页面,请先登录!</h2></s:a>
</s:if>
<s:else>
		<s:if test="message!=null">
	    	<script type="text/javascript">
	    		var message="${msg}";
	    		alert(message);
	    	</script>
	    </s:if>

	    <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i>
            <span class="crumb-name">首页</span><span class="crumb-step">&gt;</span>
            <a class="crumb-name" href="goodsList">商品管理</a><span class="crumb-step">&gt;</span>
            <span class="crumb-name">新增商品</span>
            </div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form action="addGood" method="post" onsubmit="return confirmAddGood()" enctype="multipart/form-data">
                    <table class="insert-tab" width="100%">
                        <tbody><tr>
                            <th width="120"><i class="require-red">*</i>商品类别：</th>
                            <td>
                                <s:select headerKey="-1" headerValue="商品种类" id="goodskind" name="goodskind.id" list="goodsKindList" listKey="id" listValue="name" required="required"/>
                            </td>
                        </tr>
                            <tr>
                                <th><i class="require-red">*</i>商品名称：</th>
                                <td>
                                	<s:textfield name="name" id="name" class="common-text required" size="50" required="required"></s:textfield>
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>单价(￥)：</th>
                                <td><s:textfield class="common-text required" id="price" name="price" size="50" required="required"></s:textfield>
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                                    <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>
                </form>
            </div>
        </div> 
</s:else>	
</body>
</html>
